#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
    int FindGreatestSumOfSubArray(vector<int>& array) {
        // write code here
        int retnum = array[0];
        int tmp = array[0];
        for (int i = 1; i < array.size(); ++i)
        {
            tmp = tmp + array[i] > array[i] ? tmp + array[i] : array[i];
            retnum = retnum > tmp ? retnum : tmp;
        }
        return retnum;
    }
};
int main()
{
    vector<int> array = { 10, -12, 10, 8, 9, -10, 10, 9, 8, -7 };
    cout << Solution().FindGreatestSumOfSubArray(array) << endl;
    return 0;
}